home *** CD-ROM | disk | FTP | other *** search
- Path: ucl.ac.uk!nobody
- From: hammond_g@drkclu.meng.ucl.ac.uk (G. Ruth Hammond)
- Newsgroups: comp.lang.c
- Subject: Re: Kind of an annoying question...
- Date: Wed, 20 Mar 1996 13:12:51 GMT
- Organization: UCL Dept Mech Eng
- Message-ID: <1996Mar20.131251.80856@ucl.ac.uk>
- NNTP-Posting-Host: crs4gw.crs4.it
- Originator: daemon@crs4gw.crs4.it
-
-
- In article <4iaqd4$l70@cs3.brookes.ac.uk>, Krunchie <95155580@brookes.ac.uk>
- writes:
- |>speng@stimpy.us.itd.umich.edu (Steve Palmer Peng) wrote:
- |>>I'm wondering, just what function in C allows me to enter a character
- |>>from the keyboard, and it automatically executes the command I designate
- |>>that character to. For instance, I have something like,
- |>>
- |>>printf("Enter Y or N:");
- |>>
- |>>and I want the command after the printf statement to wait for input
- |>>from the keyboard, but once someone enters a Y or an N, the next line of
- |>>code is executed, without hitting enter. Does anyone know how? It would
- |>>be greatly appreciated if someone could help me out here...
- |>>
- |>>Steve
- |>>
- |>>
- |>Here is an example of how this can easily be achieved:
- |>
- |>int main(void)
- |>{
- |>char choice;
- |>printf("Do you want to drop an H-Bomb on Iraq (Y or N)");
- |>choice=getch(); /* vital line */
- ^^^^^
-
- this is not an ANSI function, the FAQ mentions that doing this is system
- specific.
-
- --
- ~GuyRuthHammond () {}
- // Machinery and Mayhem at UCL Dept Mech Eng
- // mailto:hammond_g@meng.ucl.ac.uk http://www.ucl.ac.uk/~zcemm23
- // Clear the DECs, it's time for action!
-
-
-